package com.hgyc.mom.mes.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.hgyc.mom.common.annotation.Excel;
import com.hgyc.mom.core.annotation.DictColumn;
import com.hgyc.mom.core.annotation.TableDict;
import com.hgyc.mom.core.mybatis.EQ;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 生产工单BOM组成
 * </p>
 *
 * @author fwj
 * @since 2025-07-10
 */
@Data
@TableName("mes_work_order_bom_item")
@Schema(name="生产工单BOM组成对象", description="生产工单BOM组成对象")
public class MesWorkOrderBomItem implements Serializable {
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "BOM行ID")
    private Long id;

    @EQ
    @Schema(description = "生产工单ID")
    private Long workOrderId;

    @Excel(name = "BOM物料ID")
    @EQ
    @Schema(description = "BOM物料ID")
    @TableDict(table = "base_material", key = "id" , columns = {
            @DictColumn(name ="material_code", alias = "materialCode"),
            @DictColumn(name = "material_name", alias = "materialName"),
            @DictColumn(name = "spec", alias = "materialSpec")
    })
    private Long materialId;

    @Excel(name = "每件用量")
    @Schema(description = "每件用量")
    private BigDecimal qty;

    @Excel(name = "损耗率", readConverterExp = "%=")
    @Schema(description = "损耗率（%）")
    private BigDecimal lossRate;

    @Excel(name = "计划总用量", readConverterExp = "q=ty,×=,工=单数量,×=,(=1+损耗)")
    @Schema(description = "计划总用量（qty × 工单数量 × (1+损耗)）")
    private BigDecimal totalQty;

    @Excel(name = "是否关键物料")
    @Schema(description = "是否关键物料")
    private String isCritical;

    @Excel(name = "备注")
    @Schema(description = "备注")
    private String remark;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建者")
    private Long createBy;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.UPDATE)
    @Schema(description = "更新者")
    private Long updateBy;

    @TableField(fill = FieldFill.UPDATE)
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

}